<template>
    <el-container>
        <el-aside width="200px">
            <SideMenu />
        </el-aside>
        <el-container>
            <el-header>
                <strong>Vue后台管理系统</strong>
                <div class="header-avatar">
                    <el-avatar size="medium" :src="this.userInfo.avatar"></el-avatar>

                    <el-dropdown>
                        <span class="el-dropdown-link" style= color:#111111; >
                            {{this.userInfo.username}}<i class="el-icon-arrow-down el-icon--right" ></i>
                        </span>
                        <el-dropdown-menu slot="dropdown">
                            <el-dropdown-item>
                                <router-link to="/person">
                                个人中心
                                </router-link>
                            </el-dropdown-item>
                            <el-dropdown-item>
                                <router-link to="/login">
                                    退出
                                </router-link>
                            </el-dropdown-item>

                        </el-dropdown-menu>
                    </el-dropdown>
                    <el-link href="https://markerhub.com" target="_blank">网站</el-link>
                    <el-link href="https://markerhub.com" target="_blank">B站</el-link>

                </div>
            </el-header>
            <el-main>
<!--                <Tabs/>-->
                <div style="margin: 0 15px">
                    <router-view/>

                </div>
            </el-main>
        </el-container>
    </el-container>
</template>

<script>
    import SideMenu from "./inc/SideMenu";
    import request from "../utils/request";
    import Tabs from "./inc/Tabs";
    export default {
        name: "Home",
        //声明，方便使用
        components: {SideMenu,Tabs},
        data() {
            return {
                userInfo:{
                    id:"",
                    username:"",
                    avatar:""
                }
            }
        },
        //页面渲染加载的时候获取用户信息
        created() {
            this.getUserInfo()
        },
        methods: {
            getUserInfo(){
                let userForm = localStorage.getItem("userInfo")
                //解析成object对象才可以获取属性并赋值，更新UI
                let user = JSON.parse(userForm)
                this.userInfo.id = user.id
                this.userInfo.avatar = user.avatar
                this.userInfo.username = user.username
            },
            loginOut(){
                console.log('out...')
                this.$router.replace("/login")//跳转到主页

            }
        }
    }
</script>

<style scoped>
    .el-container {
        padding: 0;
        margin: 0;
        height: 100%;
    }

    .header-avatar {
        /*漂浮右边*/
        float: right;
        width: 210px;
        /*交叉轴*/
        display: flex;
        /*内容 伸开*/
        justify-content: space-around;
        /*上下居中*/
        align-items: center;
    }
    /*鼠标设置为小手*/
    .el-dropdown-link {
        cursor: pointer;
        color: #409EFF;
    }

    .el-header {
        background-color: #17B3A3;
        color: #333;
        text-align: center;
        line-height: 60px;
    }

    .el-aside {
        background-color: #D3DCE6;
        color: #333;
        line-height: 200px;
    }

    .el-main {
        color: #333;
        text-align: center;
        /*line-height: 160px;*/
        padding: 0;
    }

    .el-menu-vertical-demo{
        height: 100%;
    }

    a{
        text-decoration: none;
    }
</style>